package com.wxdc.nmgyt.nmgytwydc.greendao;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.wxdc.nmgyt.nmgytwydc.model.PdYfWzInfoBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "PD_YF_WZ_INFO_BEAN".
*/
public class PdYfWzInfoBeanDao extends AbstractDao<PdYfWzInfoBean, Long> {

    public static final String TABLENAME = "PD_YF_WZ_INFO_BEAN";

    /**
     * Properties of entity PdYfWzInfoBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property ID = new Property(1, String.class, "ID", false, "ID");
        public final static Property WZMC = new Property(2, String.class, "WZMC", false, "WZMC");
        public final static Property WZDM = new Property(3, String.class, "WZDM", false, "WZDM");
        public final static Property WZPD = new Property(4, String.class, "WZPD", false, "WZPD");
        public final static Property VERSION = new Property(5, String.class, "VERSION", false, "VERSION");
        public final static Property PdyfInfoId = new Property(6, Long.class, "pdyfInfoId", false, "PDYF_INFO_ID");
    }

    private Query<PdYfWzInfoBean> pdYfInfoBean_FREQUENCYWZQuery;

    public PdYfWzInfoBeanDao(DaoConfig config) {
        super(config);
    }
    
    public PdYfWzInfoBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"PD_YF_WZ_INFO_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"ID\" TEXT," + // 1: ID
                "\"WZMC\" TEXT," + // 2: WZMC
                "\"WZDM\" TEXT," + // 3: WZDM
                "\"WZPD\" TEXT," + // 4: WZPD
                "\"VERSION\" TEXT," + // 5: VERSION
                "\"PDYF_INFO_ID\" INTEGER);"); // 6: pdyfInfoId
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PD_YF_WZ_INFO_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, PdYfWzInfoBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String ID = entity.getID();
        if (ID != null) {
            stmt.bindString(2, ID);
        }
 
        String WZMC = entity.getWZMC();
        if (WZMC != null) {
            stmt.bindString(3, WZMC);
        }
 
        String WZDM = entity.getWZDM();
        if (WZDM != null) {
            stmt.bindString(4, WZDM);
        }
 
        String WZPD = entity.getWZPD();
        if (WZPD != null) {
            stmt.bindString(5, WZPD);
        }
 
        String VERSION = entity.getVERSION();
        if (VERSION != null) {
            stmt.bindString(6, VERSION);
        }
 
        Long pdyfInfoId = entity.getPdyfInfoId();
        if (pdyfInfoId != null) {
            stmt.bindLong(7, pdyfInfoId);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, PdYfWzInfoBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String ID = entity.getID();
        if (ID != null) {
            stmt.bindString(2, ID);
        }
 
        String WZMC = entity.getWZMC();
        if (WZMC != null) {
            stmt.bindString(3, WZMC);
        }
 
        String WZDM = entity.getWZDM();
        if (WZDM != null) {
            stmt.bindString(4, WZDM);
        }
 
        String WZPD = entity.getWZPD();
        if (WZPD != null) {
            stmt.bindString(5, WZPD);
        }
 
        String VERSION = entity.getVERSION();
        if (VERSION != null) {
            stmt.bindString(6, VERSION);
        }
 
        Long pdyfInfoId = entity.getPdyfInfoId();
        if (pdyfInfoId != null) {
            stmt.bindLong(7, pdyfInfoId);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public PdYfWzInfoBean readEntity(Cursor cursor, int offset) {
        PdYfWzInfoBean entity = new PdYfWzInfoBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // ID
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // WZMC
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // WZDM
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // WZPD
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // VERSION
            cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6) // pdyfInfoId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, PdYfWzInfoBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setID(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setWZMC(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setWZDM(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setWZPD(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setVERSION(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setPdyfInfoId(cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(PdYfWzInfoBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(PdYfWzInfoBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(PdYfWzInfoBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "FREQUENCYWZ" to-many relationship of PdYfInfoBean. */
    public List<PdYfWzInfoBean> _queryPdYfInfoBean_FREQUENCYWZ(Long pdyfInfoId) {
        synchronized (this) {
            if (pdYfInfoBean_FREQUENCYWZQuery == null) {
                QueryBuilder<PdYfWzInfoBean> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.PdyfInfoId.eq(null));
                pdYfInfoBean_FREQUENCYWZQuery = queryBuilder.build();
            }
        }
        Query<PdYfWzInfoBean> query = pdYfInfoBean_FREQUENCYWZQuery.forCurrentThread();
        query.setParameter(0, pdyfInfoId);
        return query.list();
    }

}
